package com.ute.chinesechess;

public class BanCo {
	public static OCo board[][] = new OCo[10][9];

	public static void KT() {
		for (int i = 0; i < 10; i++) {
			for (int j = 0; j < 9; j++) {
				board[i][j] = new OCo();
				board[i][j].Hang = -1;
				board[i][j].Cot = -1;
				board[i][j].Phe = -1;
				board[i][j].ThuTu = -1;
				board[i][j].Ten = "";
				board[i][j].Trong = true; // Di duoc
			}
		}
		//Phe 0 Quan Do
	}

	public static void Reset() {
		for (int i = 0; i < 10; i++) {
			for (int j = 0; j < 9; j++) {
				board[i][j].Hang = board[i][j].Cot = -1;
				board[i][j].Phe = board[i][j].ThuTu = -1;
				board[i][j].Ten = "";
				board[i][j].Trong = true;
			}
		}
	}

	public static void datQuanCo(String Ten, int Phe, int ThuTu, int Cot, int Hang) {
		board[Cot][Hang].Ten = Ten;
		board[Cot][Hang].Phe = Phe;
		board[Cot][Hang].ThuTu = ThuTu;
		board[Cot][Hang].Trong = false;
	}
	
	public static QuanCo timQuanCo(int i, int j) {
		QuanCo qc = new QuanCo();
		if (BanCo.board[i][j].Phe == 1) {
			int phe = 1;
			if (BanCo.board[i][j].Ten == "TOT") {
				switch (BanCo.board[i][j].ThuTu) {
				case 0:
					qc = VanCo.NguoiChoi[phe].qTot[0];
					break;
				case 1:
					qc = VanCo.NguoiChoi[phe].qTot[1];
					break;
				case 2:
					qc = VanCo.NguoiChoi[phe].qTot[2];
					break;
				case 3:
					qc = VanCo.NguoiChoi[phe].qTot[3];
					break;
				case 4:
					qc = VanCo.NguoiChoi[phe].qTot[4];
					break;
				}
			} else if (BanCo.board[i][j].Ten == "XE") {
				switch (BanCo.board[i][j].ThuTu) {
				case 0:
					qc = VanCo.NguoiChoi[phe].qXe[0];
					break;
				case 1:
					qc = VanCo.NguoiChoi[phe].qXe[1];
					break;
				}
			} else if (BanCo.board[i][j].Ten == "PHAO") {
				switch (BanCo.board[i][j].ThuTu) {
				case 0:
					qc = VanCo.NguoiChoi[phe].qPhao[0];
					break;
				case 1:
					qc = VanCo.NguoiChoi[phe].qPhao[1];
					break;
				}
			} else if (BanCo.board[i][j].Ten == "MA") {
				switch (BanCo.board[i][j].ThuTu) {
				case 0:
					qc = VanCo.NguoiChoi[phe].qMa[0];
					break;
				case 1:
					qc = VanCo.NguoiChoi[phe].qMa[1];
					break;
				}
			} else if (BanCo.board[i][j].Ten == "SY") {
				switch (BanCo.board[i][j].ThuTu) {
				case 0:
					qc = VanCo.NguoiChoi[phe].qSy[0];
					break;
				case 1:
					qc = VanCo.NguoiChoi[phe].qSy[1];
					break;
				}
			} else if (BanCo.board[i][j].Ten == "TINH") {
				switch (BanCo.board[i][j].ThuTu) {
				case 0:
					qc = VanCo.NguoiChoi[phe].qTinh[0];
					break;
				case 1:
					qc = VanCo.NguoiChoi[phe].qTinh[1];
					break;
				}
			} else if (BanCo.board[i][j].Ten == "TUONG") {
				switch (BanCo.board[i][j].ThuTu) {
				case 0:
					qc = VanCo.NguoiChoi[phe].qTuong;
					break;
				}
			}
		} else {
			int phe = 0;
			if (BanCo.board[i][j].Ten == "TOT") {
				switch (BanCo.board[i][j].ThuTu) {
				case 0:
					qc = VanCo.NguoiChoi[phe].qTot[0];
					break;
				case 1:
					qc = VanCo.NguoiChoi[phe].qTot[1];
					break;
				case 2:
					qc = VanCo.NguoiChoi[phe].qTot[2];
					break;
				case 3:
					qc = VanCo.NguoiChoi[phe].qTot[3];
					break;
				case 4:
					qc = VanCo.NguoiChoi[phe].qTot[4];
					break;
				}
			} else if (BanCo.board[i][j].Ten == "XE") {
				switch (BanCo.board[i][j].ThuTu) {
				case 0:
					qc = VanCo.NguoiChoi[phe].qXe[0];
					break;
				case 1:
					qc = VanCo.NguoiChoi[phe].qXe[1];
					break;
				}
			} else if (BanCo.board[i][j].Ten == "PHAO") {
				switch (BanCo.board[i][j].ThuTu) {
				case 0:
					qc = VanCo.NguoiChoi[phe].qPhao[0];
					break;
				case 1:
					qc = VanCo.NguoiChoi[phe].qPhao[1];
					break;
				}
			} else if (BanCo.board[i][j].Ten == "MA") {
				switch (BanCo.board[i][j].ThuTu) {
				case 0:
					qc = VanCo.NguoiChoi[phe].qMa[0];
					break;
				case 1:
					qc = VanCo.NguoiChoi[phe].qMa[1];
					break;
				}
			} else if (BanCo.board[i][j].Ten == "SY") {
				switch (BanCo.board[i][j].ThuTu) {
				case 0:
					qc = VanCo.NguoiChoi[phe].qSy[0];
					break;
				case 1:
					qc = VanCo.NguoiChoi[phe].qSy[1];
					break;
				}
			} else if (BanCo.board[i][j].Ten == "TINH") {
				switch (BanCo.board[i][j].ThuTu) {
				case 0:
					qc = VanCo.NguoiChoi[phe].qTinh[0];
					break;
				case 1:
					qc = VanCo.NguoiChoi[phe].qTinh[1];
					break;
				}
			} else if (BanCo.board[i][j].Ten == "TUONG") {
				switch (BanCo.board[i][j].ThuTu) {
				case 0:
					qc = VanCo.NguoiChoi[phe].qTuong;
					break;
				}
			}
		}
		return qc;
	}
}
